home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / tsfaqp34.zip / FAQPAS5.TXT < prev    next >
Text File  |  1996-09-14  |  5KB  |  126 lines

  1. From ts@uwasa.fi Sat Sep 14 00:00:00 1996
  2. Subject: FAQPAS5.TXT contents
  3.  
  4.                                Copyright (c) 1993-1996 by Timo Salmi
  5.                                                  All rights reserved
  6.  
  7. FAQPAS5.TXT The fifth set of frequently (and not so frequently)
  8. asked Turbo Pascal questions with Timo's answers. The items are in
  9. no particular order.
  10.  
  11. You are free to quote brief passages from this file provided you
  12. clearly indicate the source with a proper acknowledgment.
  13.  
  14. Comments and corrections are solicited. But if you wish to have
  15. individual Turbo Pascal consultation, please post your questions to
  16. a suitable Usenet newsgroup like news:comp.lang.pascal.borland. It
  17. is much more efficient than asking me by email. I'd like to help,
  18. but I am very pressed for time. I prefer to pick the questions I
  19. answer from the Usenet news. Thus I can answer publicly at one go if
  20. I happen to have an answer. Besides, newsgroups have a number of
  21. readers who might know a better or an alternative answer. Don't be
  22. discouraged, though, if you get a reply like this from me. I am
  23. always glad to hear from fellow Turbo Pascal users.
  24.  
  25. ....................................................................
  26. Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
  27. Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
  28. Department of Accounting and Business Finance  ; University of Vaasa
  29. mailto:ts@uwasa.fi  <URL:http://uwasa.fi/~ts>  ; FIN-65101,  Finland
  30.  
  31. --------------------------------------------------------------------
  32. 101) How do I detect if mouse hardware/driver is installed?
  33. 102) How can I read absolute sectors directly from a floppy?
  34. 103) How can I move a file to another directory in Turbo Pascal?
  35. --------------------------------------------------------------------
  36.  
  37. From ts@uwasa.fi Sat Sep 14 00:01:41 1996
  38. Subject: Detecting mouse
  39.  
  40. 101. *****
  41.  Q: How do I detect if mouse hardware/driver is installed?
  42.  
  43.  A: The source code is given below. For more mouse related functions
  44. please see ftp://garbo.uwasa.fi/pc/programming/inter51c.zip for
  45. interrupt $33 functions.
  46.   uses Dos;
  47.   (* Detect if mouse hardware/driver is installed; initializes driver *)
  48.   function MOUSDRFN : boolean;
  49.   var regs : registers;
  50.   begin
  51.     FillChar (regs, SizeOf(regs), 0);  { Just to make sure }
  52.     regs.ax := $0000;                  { Interrupt function number }
  53.     Intr ($33, regs);                  { Call interrupt $33 }
  54.     if regs.ax = $FFFF then
  55.       mousdrfn := true
  56.       else mousdrfn := false;
  57.   end;  (* mousedrfn *)
  58. --------------------------------------------------------------------
  59.  
  60. From ts@uwasa.fi Sat Sep 14 00:01:42 1996
  61. Subject: Reading absolute sectors
  62.  
  63. 102. *****
  64.  Q: How can I read absolute sectors directly from a floppy?
  65.  
  66.  A: Here is the source code for reading directly from a floppy disk.
  67. For directly reading data from hard disk, please study the
  68. information for interrupt $13 function $02 in Ralf Brown's list of
  69. interrupts ftp://garbo.uwasa.fi/pc/programming/inter51a.zip.
  70.   uses Dos;
  71.   type readBufferType = array [1..1024] of byte;
  72.   procedure READFLPY (drive  : char;
  73.                       side   : byte;
  74.                       track  : byte;
  75.                       sector : byte;
  76.                       var rb : readBufferType;
  77.                       var ok : boolean);
  78.   var regs : registers;
  79.        i : byte;
  80.   begin
  81.     ok := false;
  82.     for i := 1 to 3 do begin
  83.       FillChar (regs, SizeOf(regs), 0);  { Just to make sure }
  84.       regs.ah := $02;                    { Function }
  85.       regs.al := 2;                      { Number of sectors to read }
  86.       regs.dl := ord(Upcase(drive))-ord('A');
  87.       if (regs.dl < 0) or (regs.dl > 1) then exit;   { For floppies only }
  88.       regs.dh := side;
  89.       regs.ch := track;
  90.       regs.cl := sector;
  91.       regs.es := Seg(rb);
  92.       regs.bx := Ofs(rb);
  93.       Intr ($13, regs);                  { Call interrupt $13 }
  94.       if regs.flags and FCarry = 0 then begin   { Was it ok? }
  95.         ok := true; exit;
  96.       end; {if}
  97.       { reset and try again a maximum of three times }
  98.       FillChar (regs, SizeOf(regs), 0);  { Just to make sure }
  99.       regs.ah := $00;                    { Function }
  100.       regs.dl := ord(Upcase(drive))-ord('A');
  101.     end; {for i}
  102.   end;  (* readflpy *)
  103. --------------------------------------------------------------------
  104.  
  105. From ts@uwasa.fi Sat Sep 14 00:01:43 1996
  106. Subject: Moving files
  107.  
  108. 103. *****
  109.  Q: How can I move a file to another directory in Turbo Pascal?
  110.  
  111.  A: If the file and the target directory are on the same disk you
  112. can use Turbo Pascal's rename command for the purpose. If they are
  113. on separate disks you'll first have to copy the file as explained in
  114. the item "How can I copy a file in a Turbo Pascal program?" and then
  115. erase the original as explained in the item "Can you tell a beginner
  116. how to delete files with Turbo Pascal?"
  117.   var f : file;
  118.   begin
  119.     Assign (f, 'r:\faq.pas');
  120.     {$I-} Rename (f, 'r:\cmand\faq.pas'); {$I+}
  121.     if IOResult = 0 then
  122.       writeln ('File moved') else writeln ('File not moved');
  123.   end.
  124. --------------------------------------------------------------------
  125.  
  126.